import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Confirm from 'vux/src/components/confirm/index.vue'

export default {
  name: 'pointto',
  components: {Confirm},
  data () {
    return {
      siteId: '',
      studentId: '',
      // 今日点到
      content: [],
      // 点到统计
      list: [],
      show: false
    }
  },
  mounted () {
    var _this = this
    _this.siteId = window.sessionStorage.getItem('siteId')
    _this.studentId = window.sessionStorage.getItem('studentId')
    if (_this.studentId == '-1') {
      _this.show = true
    } else {
      http.get(CONSTANT.STUDENTSIGNTODAY + '?siteId=' + _this.siteId + '&studentId=' + _this.studentId, {}, (res) => {
        console.log('jinri', res)
        // 我的点到 今日点到
        if (res.length > 0) {
          _this.content = res
        }
      })
      http.get(CONSTANT.SIGNTERM + '?siteId=' + _this.siteId + '&studentId=' + _this.studentId, {}, (res) => {
        console.log('tongji', res)
        // 我的点到 点到统计
        if (res.length > 0) {
          _this.list = res
          console.log(_this.list[1].timeable)
          for (var i = 0; i < _this.list.length; i++) {
            if (_this.list[i].timeable.indexOf('\r\n') > -1) {
              _this.list[i].timeable = _this.list[i].timeable.split('\r\n')
              console.log(_this.list[i])
              console.log(typeof _this.list[i].timeable)
            }
          }
        }
      })
    }
  },
  methods: {
    onCancel () {
      // 取消按钮
    },
    onConfirm () {
    //  确定按钮
      var _this = this
      _this.$router.push({path: '/login'})
    },
    goPointtoDetails (id) {
      var _this = this
      window.sessionStorage.setItem('classId', id)
      _this.$router.push({path: '/pointtoList'})
    }
  }
}
